import requests
from lxml import etree
import time
url = 'http://jnzyk.36ve.com/Education/forum/index?tcourseId=1a1c4f42-d322-39dc-b54d-59644573431b'
url = 'http://jnzyk.36ve.com/Education/forum/index?tcourseId=cbf16b6e-39fc-371c-bf89-fe926a28c9c3'
#课程id获取
cok = \
    '__root_domain_v=.36ve.com; _qddaz=QD.caew7w.5ccl0b.khj5tg06; _qdda=3-1.1; _qddab=3-qdpkzj.khxd8aie; _qddamta_2852103590=3-0; PHPSESSID=r7jvqlnjg7dchndg67t1r2kkpf; _csrf=57a60352b637aaf2be26d9f0ce154c0368185b4e6a627190849dc4eb2a89034fa%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%227LEEaXwU6U1uSOrIscvdJkzHf5zxIDW5%22%3B%7D'
def Id():
    url ='http://jnzyk.36ve.com/index.php/course/student-learning-course'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0'
    ,'Host': 'jnzyk.36ve.com','Cookie':cok}
    r = requests.get(url,headers=headers)
    html = etree.HTML(r.text)
    id = html.xpath('//*[@id="example"]/tbody/tr/td[6]/a[2]/@course_id')
    return id
def tl():
    for i in Id():
        url = 'http://jnzyk.36ve.com/Education/forum/index?tcourseId='+i
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0'
            , 'Host': 'jnzyk.36ve.com', 'Cookie': cok}
        r = requests.get(url,headers=headers)
        print()
        break
def huifu():
    url = 'http://jnzyk.36ve.com/Education/forum/forum-comment-add'
    data = {
        #课程id
        'topic_id': 'e7dd4ee8-783c-34a8-8b02-5e0f26a8621f',
        'content': '孔子说,“不学礼,无以立”.就是说,你不学“礼”,就没法在社会中立身.那么,什么是礼仪呢?简单地说,礼仪就是律己、敬人的一种行为规范,是表现对他人尊重和理解的过程和手段.文明礼仪,不仅是个人素质、教养的体现,也是个人道德和社会公德的体现.更是城市的脸面,更是国家的脸面.所以,学习礼仪不仅可以内强个人素质、外塑单位更能够润滑和改善人际关系。',
        'pid': '',
        'tcourseId': '1a1c4f42-d322-39dc-b54d-59644573431b',
        'bcourseId': '39859417-af13-3e9c-a238-729d2f3bd0f1',
        '_csrf': 'eESpTYBuDFDOj4Tp9CvczHLi_VqKFjdegfizaEHDn7ZPCOwI4TZ7BfjatZynZK6FAYGLPsB9TRbnzckQCIfIgw=='
    }
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0'
    ,'Host': 'jnzyk.36ve.com','Cookie':cok}
    r = requests.post(url,headers=headers,data=data)
def biji():
    url = 'http://jnzyk.36ve.com/Student/note/add-note?tcourseId=1a1c4f42-d322-39dc-b54d-59644573431b'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0'
    ,'Host': 'jnzyk.36ve.com','Cookie':cok}
    data = {
        'NoteForm[title]': '三思而后行',
        'NoteForm[content]': '孔子会唱歌、弹琴、击磬可以说是一位音乐的全才。',
        'files':'',
    'image': '',
    'video': '',
    'audio': '',
    'doc': '',
    'delete': ''
    }
    r = requests.post(url,headers=headers,data=data)
    print(r)
if __name__ == '__main__':
    for i in range(1,50):
        time.sleep(1)
        biji()